#pragma once
#include <string>
#include <cstring>
#include "Log.hpp"

using namespace LogMudule;

class Command
{
public:
    std::string Excute(const std::string &command)
    {
        // 相当于pipe + excl
        FILE *fp = popen(command.c_str(), "r");
        if (fp == nullptr)
            return std::string();
        char buffer[1024];
        std::string result;
        while (fgets(buffer, sizeof(buffer), fp))
        {
            result += buffer;
        }
        pclose(fp);
        return result;
    }
};